package com.weimob.mcloud.wechatwork.customer.service.user.base;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.weimob.mcloud.wechatwork.common.support.codec.serializer.LongSerializer;
import com.weimob.zipkin.ZipkinContext;

import java.io.Serializable;

/**
 * Create Time: 2021年10月20日 17:10
 *
 * @author maosheng.li
 **/
public class BaseResponse<T> implements Serializable {

    @JsonSerialize(using = LongSerializer.class)
    private Long errcode = 0L;
    private String errmsg = "操作成功";
    private T data;
    private String globalTicket;

    public BaseResponse(T data) {
        this("操作成功", data);
    }

    public BaseResponse(String message, T data) {
        this(0L, message, data);
    }

    public BaseResponse(Long code, String message) {
        this(code, message, null);
    }

    public BaseResponse(Long code, String message, T data) {
        this(code, message, data, ZipkinContext.getContext().getGlobalTicket());
    }

    public BaseResponse(Long code, String message, T data, String globalTicket) {
        this.errcode = code;
        this.errmsg = message;
        this.data = data;
        this.globalTicket = globalTicket;
    }



    public Long getErrcode() {
        return errcode;
    }

    public void setErrcode(Long errcode) {
        this.errcode = errcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getGlobalTicket() {
        return globalTicket;
    }

    public void setGlobalTicket(String globalTicket) {
        this.globalTicket = globalTicket;
    }
}
